<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix='c'	uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function checkedText(){
	var com = document.getElementById("com");
	
	if(com.value.length <10){
		alert("평가는 10글자 이상 해주세요.");
		return false;
	}
}

function giveGrade(){
	var flag = window.confirm("평점을 주시겠습니까?");
	if(!flag){
		return false;
	}
}

function hSizeUp(){
	var trSize = document.getElementById("commentList");
	trSize.setAttribute("height","*");
}
</script>
</head>
<body>
<c:if test="${requestScope.error_message } != null">
<script type="text/javascript">
	alert("${requestScope.error_message}");
</script>
</c:if>
<table width="600" height="600" border="1">
	<tr><td colspan="2" align="center"><h2> ${requestScope.muto.menuName }</h2></td></tr>
	<tr height="10" align="center" >
		<td>사진</td>
		<td>설명</td>
	</tr>	
	<tr>
		<td><img src="${requestScope.muto.imgLocation }"> </td>
		<td>${requestScope.muto.explanation }</td>
	</tr>
	<tr height="20">
		<td>평점 : ${requestScope.muto.grade }</td>
		<td>
		<form action="addGrade.do" onsubmit="return giveGrade()" method="post">
		<input type="hidden" name="menuId" id="menuId" value="${requestScope.muto.menuId }">
		<select id="greadeSelect" name="grSel">
			<option value="1">1점( 이게 음식이냐 )</option>
			<option value="2">2점</option>
			<option value="3">3점</option>
			<option value="4">4점</option>
			<option value="5" selected>5점( 걍 평타 )</option>
			<option value="6">6점</option>
			<option value="7">7점</option>
			<option value="8">8점</option>
			<option value="9">9점</option>
			<option value="10">10점( -_-)b )</option>
		</select><input type="submit" value="평점주기"> </form></td>
	</tr>
	<tr id="commentList" height="200">
		<td colspan="2">
		<table border="1" width=500>
			<tr>
				<td width="350">내용</td>
				<td width="50">작성자</td>
				<td width="100">작성일</td>
			</tr>
			<c:forEach items="${requestScope.commentList }" var="comment" >
				<tr>
				<td>${comment.commentContent }</td><td>${comment.writer }</td><td>${comment.commentDate }</td>
				</tr>
			</c:forEach>
			
		</table>
		
			<input type="button" id="hSize" value="더보기" onclick="hSizeUp();">
		
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<form action="commentWrite.do" method="post" onsubmit="return checkedText();">
			<textarea name="comm" id="comm" rows="5px" cols="50px"></textarea>
			<input type="hidden" name="menuId" id="menuId" value="${requestScope.muto.menuId }">
			<input type="submit" value="맛평가">
		</form>
		</td>
	</tr>
</table>
</body>
</html>